package com.sl.biz.modular.workflow.dao.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sl.biz.modular.views.dao.domain.entity.ViewConfigDO;
import com.sl.biz.modular.views.dao.mapper.ViewConfigMapper;
import com.sl.biz.modular.workflow.dao.domain.entity.WorkflowDO;
import com.sl.biz.modular.workflow.dao.mapper.WorkflowMapper;
import com.sl.biz.modular.workflow.dao.service.WorkflowDaoService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class WorkflowDaoServiceImpl extends ServiceImpl<WorkflowMapper, WorkflowDO> implements WorkflowDaoService {


    @Override
    public WorkflowDO queryByCode(String workflowCode) {
        LambdaQueryWrapper<WorkflowDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(WorkflowDO::getWorkflowCode, workflowCode);
        return super.getOne(lambdaQueryWrapper);
    }

    @Override
    public List<WorkflowDO> queryByCondition(WorkflowDO workflowDO) {
        LambdaQueryWrapper<WorkflowDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(StrUtil.isNotBlank(workflowDO.getGroupId()), WorkflowDO::getGroupId, workflowDO.getGroupId());
        lambdaQueryWrapper.eq(StrUtil.isNotBlank(workflowDO.getProductId()), WorkflowDO::getProductId, workflowDO.getProductId());
        return super.list(lambdaQueryWrapper);
    }
}
